//Import model
package tecpointbenchmark.controller;

import java.util.ArrayList;
import java.util.Observer;
import tecpointbenchmark.model.*;
import tecpointbenchmark.model.dto.*;

/**
 * The controller - All the method calls passes thru here.
 * 
 * @author Rafel & Tom
 */

public class Controller {

	ModuleHandler moduleHandler = new ModuleHandler();
	ResultDTO resultDTO = new ResultDTO();

	/**
	 * Returns all modules.
	 * 
	 * @return returns an ArrayList with all the modules.
	 */
	public ArrayList<ModuleInfoDTO> getModules() {
		return (moduleHandler.getModules());
	}

	/**
	 * Calls a method in DTO that runs benchmark
	 * 
	 * @param id
	 *            , id for the module
	 * @return returns the state for the module as a <code>StateDTO</code>
	 *         -object.
	 */
	public void runBenchmark(int id) {
		moduleHandler.runBenchmark(id);
	}

	/**
	 * Calls a method in DTO that stops benchmark
	 */
	public void stopBenchmark() {
		moduleHandler.stopBenchmark(false);
	}

	/**
	 * Calls a method in DTO that returns the state of a module
	 */
	public ResultDTO getModuleState() {
		resultDTO = moduleHandler.getModuleState();
		return resultDTO;
	}

	public void setObserver(Observer o) {
		moduleHandler.addObserver(o);
	}
}
